package khleuven.mondzorg.domain;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.lang.reflect.Constructor;

import org.json.JSONObject;

public enum EntryType implements Comparable<EntryType> {
	DEFINITION(Definition.class, "defs.json"),
	FAQ(Faq.class, "faqs.json"),
	LEARN(Learn.class, "learns.json"),
	TEST(Test.class, "tests.json"),
	ILLUSTRATION(Illustration.class, "illustrations.json");
	
	private Constructor<? extends MondAppEntry> entryConstructor;
	private String offline_storing_file;
	private FileOutputStream fileOutput;
	private FileInputStream fileInput;
	
	private EntryType(Class<? extends MondAppEntry> c, String offline_storing_file) {
		try {
			this.entryConstructor = c.getConstructor(JSONObject.class);
		} catch (NoSuchMethodException e) {
			throw new RuntimeException(e);
		}
		this.offline_storing_file = offline_storing_file;
	}
	
	public Constructor<? extends MondAppEntry> getConstructor() {
		return this.entryConstructor;
	}
	
	public String getOfflineFile(){
		return this.offline_storing_file;
	}
	
	public void setFileOutputStream(FileOutputStream fos){
		this.fileOutput = fos;
	}
	
	public FileOutputStream getFileOutputStream(){
		return this.fileOutput;
	}
	
	public void setFileInputStream(FileInputStream fis){
		this.fileInput = fis;
	}
	
	public FileInputStream getFileInputStream(){
		return this.fileInput;
	}
}


